package com.booklove.controller;


import com.booklove.constant.JwtClaimsConstant;
import com.booklove.properties.JwtProperties;
import com.booklove.utils.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-09-20
 */
@RestController
@RequestMapping("/test")
public class ItemController {
    @Autowired
    private JwtProperties jwtProperties;

    @PostMapping("/login")
    public String item() {
        HashMap<String, Object> claims = new HashMap<>();
        claims.put(JwtClaimsConstant.USER_ID, -1);
        String token = JwtUtil.createJWT(jwtProperties.getUserSecretKey(), jwtProperties.getUserTtl(), claims);

        return token;
    }

    @PostMapping("/itemback")
    public String itemback() {
        return "nihao";
    }

}
